import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {

  id?: number,
  projectName?: string,
  productInfo?: string,
  deviceSN?: string,
  flowCardNum?: string,
  IccId?: string,
  status?: number,
  operator?: string,
  canal?: string,
  lastFlow?: string,
  activeDate?: string,
  expireDate?: string,
  deviceId?: string,
  personal?: string,
  unity?: string,
  unityId?: number,
  unityName?: string,
}
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = '/system/product/flowcard/v2/flowcards';
const Url = '/system/product/flowcard/v2/flowcard';
export const getList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", List, {
    params
  });
};
export const getInfo = (params?: object) => {
  return http.request<commonResult<infoType>>("get", Url, {
    params
  });
};
export const addInfo = (data?: object) => {
  return http.request<commonResult<any>>("post", Url, {
    data
  });
};
export const editInfo = (data?: object) => {
  return http.request<commonResult<any>>("put", Url, {
    data
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};
/** 1.1.4.4导入流量卡 */
export const importFlowCard = (data?: object) => {
  return http.request<commonResult<any>>("post", '/system/product/flowcard/v2/import', {
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};
/** 1.1.4.2获取运营商下拉框 */
export const getOperatorList = (data?: object) => {
  return http.request<commonResult<any>>("get", '/system/product/flowcard/v2/operator', {
    data
  });
};
/** 1.1.4.3获取渠道商下拉框 */
export const getCanalList = (data?: object) => {
  return http.request<commonResult<any>>("get", '/system/product/flowcard/v2/canal', {
    data
  });
};
/** 1.6.2.8转移流量卡 */
export const transforFlowCard = (data?: object) => {
  return http.request<commonResult<any>>("post", '/system/product/flowcard/v2/transfer', {
    data
  });
};
/** 1.6.2.9转移/续费流量卡号列表 */
export const getTransferList = (data?: object) => {
  return http.request<commonResult<any>>("get", '/system/product/flowcard/v2/list', {
    data
  });
};
/** 1.6.2.10流量卡续费 */
export const rechargeFlowCard = (data?: object) => {
  return http.request<commonResult<any>>("post", '/system/product/flowcard/v2/renew', {
    data
  });
};

/** 1.10.1.5服务续费的设备列表*/
export const getdeviceSNList = (data?: object) => {
  return http.request<commonResult<any>>("get", '/system/personal/device/v2/list', {
    data
  });
};